/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author Alumno
 */
public class NewJFrameInicio extends javax.swing.JFrame {

    JFrameFicheros jfFich;
    JFrameCrearBd jfCrearBd;
    JFileChooser jfileChooser;

    /**
     * Creates new form NewJFrameInicio
     */
    public NewJFrameInicio() {
        initComponents();
        String workingdir = System.getProperty("user.dir");
        jfileChooser = new JFileChooser(new File(workingdir));

        MenuDesconectarBD.setEnabled(false);
        MenuEjecutarComandoBD.setEnabled(false);
        MenuRenombrarBD.setEnabled(false);
        MenuPropiedadesBD.setEnabled(false);
        jfFich = new JFrameFicheros();
        jfCrearBd = new JFrameCrearBd();
        this.setLocationRelativeTo(null);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        MenuAbrirDom = new javax.swing.JMenuItem();
        MenuAbrirSax = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        MenuAbrirTexto = new javax.swing.JMenuItem();
        MenuAbrirBinario = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        MenuCrearBD = new javax.swing.JMenuItem();
        MenuConectarBD = new javax.swing.JMenuItem();
        MenuDesconectarBD = new javax.swing.JMenuItem();
        MenuEjecutarComandoBD = new javax.swing.JMenuItem();
        MenuRenombrarBD = new javax.swing.JMenuItem();
        MenuPropiedadesBD = new javax.swing.JMenuItem();
        MenuSalir = new javax.swing.JMenu();
        MenuSalirSalir = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Base de datos de Motos");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        jMenu3.setText("Ficheros");

        MenuAbrirDom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        MenuAbrirDom.setText("Abrir XML_DOM");
        MenuAbrirDom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuAbrirDomActionPerformed(evt);
            }
        });
        jMenu3.add(MenuAbrirDom);

        MenuAbrirSax.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        MenuAbrirSax.setText("Abrir XML_SAX");
        MenuAbrirSax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuAbrirSaxActionPerformed(evt);
            }
        });
        jMenu3.add(MenuAbrirSax);
        jMenu3.add(jSeparator1);

        MenuAbrirTexto.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        MenuAbrirTexto.setText("Abrir Fichero Texto");
        MenuAbrirTexto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuAbrirTextoActionPerformed(evt);
            }
        });
        jMenu3.add(MenuAbrirTexto);

        MenuAbrirBinario.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK));
        MenuAbrirBinario.setText("Abrir Fichero Binario");
        MenuAbrirBinario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuAbrirBinarioActionPerformed(evt);
            }
        });
        jMenu3.add(MenuAbrirBinario);

        jMenuBar1.add(jMenu3);

        jMenu1.setText("BDR");

        MenuCrearBD.setText("Crear");
        MenuCrearBD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuCrearBDActionPerformed(evt);
            }
        });
        jMenu1.add(MenuCrearBD);

        MenuConectarBD.setText("Conectar...");
        MenuConectarBD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuConectarBDActionPerformed(evt);
            }
        });
        jMenu1.add(MenuConectarBD);

        MenuDesconectarBD.setText("Desconectar");
        jMenu1.add(MenuDesconectarBD);

        MenuEjecutarComandoBD.setText("Ejecutar comando");
        jMenu1.add(MenuEjecutarComandoBD);

        MenuRenombrarBD.setText("Renombrar");
        jMenu1.add(MenuRenombrarBD);

        MenuPropiedadesBD.setText("Propiedades");
        jMenu1.add(MenuPropiedadesBD);

        jMenuBar1.add(jMenu1);

        MenuSalir.setText("Salir");

        MenuSalirSalir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        MenuSalirSalir.setText("Salir");
        MenuSalirSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuSalirSalirActionPerformed(evt);
            }
        });
        MenuSalir.add(MenuSalirSalir);

        jMenuBar1.add(MenuSalir);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void MenuAbrirDomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuAbrirDomActionPerformed
        this.setVisible(false);
        jfFich.setMenuAbrirDom();
        jfFich.setVisible(true);

    }//GEN-LAST:event_MenuAbrirDomActionPerformed

    private void MenuAbrirSaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuAbrirSaxActionPerformed
        this.setVisible(false);
        jfFich.setMenuAbrirSax();
        jfFich.setVisible(true);
    }//GEN-LAST:event_MenuAbrirSaxActionPerformed

    private void MenuAbrirTextoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuAbrirTextoActionPerformed
        this.setVisible(false);
        jfFich.setMenuAbrirTexto();
        jfFich.setVisible(true);
    }//GEN-LAST:event_MenuAbrirTextoActionPerformed

    private void MenuAbrirBinarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuAbrirBinarioActionPerformed
        this.setVisible(false);
        jfFich.setMenuAbrirBinario();
        jfFich.setVisible(true);
    }//GEN-LAST:event_MenuAbrirBinarioActionPerformed

    private void MenuSalirSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuSalirSalirActionPerformed
        int dialogResult = JOptionPane.showConfirmDialog(null, "¿Estás seguro de que quieres salir?", "Warning", JOptionPane.YES_NO_OPTION);

        if (dialogResult == JOptionPane.YES_OPTION) {
            System.exit(0);
        }
    }//GEN-LAST:event_MenuSalirSalirActionPerformed

    private void MenuCrearBDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuCrearBDActionPerformed
        //this.setVisible(false);
        jfCrearBd.setVisible(true);
    }//GEN-LAST:event_MenuCrearBDActionPerformed

    private void MenuConectarBDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuConectarBDActionPerformed
        jfileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jfileChooser.setFileFilter(new FileNameExtensionFilter("Archivos SQLite", "sqlite"));
        int opcion = jfileChooser.showOpenDialog(null);
        String ficheroSeleccioado = jfileChooser.getSelectedFile().getName();
        
        
    }//GEN-LAST:event_MenuConectarBDActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrameInicio().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem MenuAbrirBinario;
    private javax.swing.JMenuItem MenuAbrirDom;
    private javax.swing.JMenuItem MenuAbrirSax;
    private javax.swing.JMenuItem MenuAbrirTexto;
    private javax.swing.JMenuItem MenuConectarBD;
    private javax.swing.JMenuItem MenuCrearBD;
    private javax.swing.JMenuItem MenuDesconectarBD;
    private javax.swing.JMenuItem MenuEjecutarComandoBD;
    private javax.swing.JMenuItem MenuPropiedadesBD;
    private javax.swing.JMenuItem MenuRenombrarBD;
    private javax.swing.JMenu MenuSalir;
    private javax.swing.JMenuItem MenuSalirSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    // End of variables declaration//GEN-END:variables
}
